package com.code;

/**
 * Created by lucky on 2018/10/26.
 */



public class Code10 {


    public static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;
        TreeNode(int x) { val = x; }
    }

    public static int maxDepth(TreeNode root) {
        return root == null ? 0 : (1 + Math.max(maxDepth(root.left), maxDepth(root.right)));
    }

    public static void main(String[] args) {
        TreeNode root = new TreeNode(3);
        TreeNode root1 = new TreeNode(9);
        TreeNode root2 = new TreeNode(15);
        root.left = root1;
        root.right = null;
        root.left.left = root2;
        int i = maxDepth(root);
        System.out.println(i);
    }
}
